﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System.Windows;
using System.Windows.Media.Imaging;
using Microsoft.Phone.Controls;

namespace FeatureOverview.Features.Tasks
{
    public partial class CameraCaptureTask : PhoneApplicationPage
    {
        public CameraCaptureTask()
        {
            InitializeComponent();
        }

        private void _takePicture_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Phone.Tasks.CameraCaptureTask cct 
                = new Microsoft.Phone.Tasks.CameraCaptureTask();
            cct.Completed 
                += new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(cct_Completed);
            cct.Show();
        }

        void cct_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
        {
            BitmapImage bmp = new BitmapImage();    
            bmp.SetSource(e.ChosenPhoto);
            _image.Source = bmp;
        }
    }
}